﻿using System.Collections.Generic;
using System.Linq;
using Cassandraemon.Connection;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Cassandraemon.Test
{
	[TestClass]
	public class ManualNodeEnumeratorTest
	{
		[TestMethod]
		public void ManualNodeEnumeratorConstructorTest()
		{
			var hosts = new[] { "a", "b", "c" };
			var target = new ManualNodeEnumerator(hosts);
			CollectionAssert.AreEqual(hosts, target.Nodes.ToArray());
		}

		[TestMethod]
		public void ManualNodeEnumeratorExcludeTest()
		{
			var hosts = new[] { "localhost", "a", "b", "c", "d" };
			var target = new ManualNodeEnumerator(hosts);
			CollectionAssert.AreEqual(hosts, target.Nodes.ToArray());

			var excludes = new[] { "localhost", "c" };
			target.SetExcludes(excludes);
			var expected = hosts.Except(excludes).ToArray();
			CollectionAssert.AreEqual(expected, target.Nodes.ToArray());

			target.SetNodes(hosts);
			CollectionAssert.AreEqual(expected, target.Nodes.ToArray());
		}
	}
}
